import request from "@/utils/request"
import Vue from 'vue'
export const downloadmusic = (filePath,fileName)=>{
 
   request({
     method: "GET", 
     url:filePath,
     responseType:"blob" })
     .then((res) => {
        console.log(res);
        let blob = res.data;
        let href = URL.createObjectURL(blob);
        console.log(href);
        let a = document.createElement("a");
        a.href = href;
        a.download = fileName
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        Vue.prototype.$message.success(`${fileName}下载成功`)
    })
    .catch((err) => {
        console.log(err);
        Vue.prototype.$message.$message.error('下载失败,请稍后重试!')
    });

}
